<template>
	<view class="main-content">
		<MHeader>{{ state.pageName }}</MHeader>
		<scroll-view scroll-y="true" style="height: calc(100% - 80rpx)">
			<view>
				<item name="单据编号">
					<view class="input">{{state.info.Data.BillNo}}</view>
				</item>
				<item name="状态">
					<view class="input">{{state.info.Data.DocumentStatus?state.status[state.info.Data.DocumentStatus]:''}}</view>
				</item>
				<item name="日期">
					<view class="input">{{state.info.Data.F_QUQY_Date?moment(state.info.Data.F_QUQY_Date).format('YYYY-MM-DD'):' '}}</view>
				</item>
				<item name="技术员">
					<view>{{state.info.Data.F_QUQY_Applicant?.Name[0].Value}}</view>
				</item>
				<item name="组织">
					<view>{{state.info.Data.F_QUQY_OrgId?.Name[0].Value}}</view>
				</item>
				<item name="调拨方向">
					<view>{{state.dbList[state.info.Data.F_QUQY_TransferDirect]}}</view>
				</item>
			</view>
			<MHeader hidTag v-if="state.info.Data.FEntity">
				<van-icon name="cluster" color="#1989fa" style="margin-right: 10rpx" />
				兽药调拨列表
			</MHeader>
			<view style="padding-bottom: 10rpx">
				<view class="card" v-for="(item, index) in state.info.Data.FEntity">
					<view class="card-index">{{ index + 1 }}</view>
					<item name="物料编码">
						<view>{{item.F_QUQY_MaterialID?.Number}}</view>
					</item>
					<item name="物料名称">
						<view>{{item.F_QUQY_MaterialID?.Name[0].Value}}</view>
					</item>
					<item name="单位">
						<view>{{item.F_QUQY_Unit?.Name[0].Value}}</view>
					</item>
					<item name="调出仓库">
						<view>{{item.F_QUQY_StoreOut?.Name[0].Value}}</view>
					</item>
					<item name="调入仓库">
						<view>{{item.F_QUQY_StoreIn?.Name[0].Value}}</view>
					</item>
					<item name="数量">
						<view>{{item.F_QUQY_Qty}}</view>
					</item>
					<item name="含税单价">
						<view style="padding-right: 35rpx;">{{item.F_QUQY_UnitPrice}}</view>
						<text class="symbol">元</text>
					</item>
					<item name="价税合计">
						<view style="padding-right: 35rpx;">{{item.F_QUQY_TotalTaxAmount}}</view>
						<text class="symbol">元</text>
					</item>
				</view>
			</view>
		</scroll-view>
	</view>
	<Loading v-if="state.loading"></Loading>
</template>

<script setup>
	import moment from 'moment'
	import { reactive, ref, nextTick } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { msg } from '/utils/utils.js'
	import kdApis from '/api/modularApi/kdApi.js'
	import { next } from 'lodash-es'
	const state = reactive({
		info: {
			FormId: 'QUQY_VeterinaryDrugAllot',
			Data: {}
		},
		status: {
			Z: '暂 存',
			A: '保 存',
			B: '审核中',
			C: '已审核',
			D: '重新审核'
		},
		loading: true,
		dbList: {
			GENERAL: '普通',
			RETURN: '退货',
		},
	});

	const getDetails = (Id) => {
		kdApis.formView({
			formId: 'QUQY_VeterinaryDrugAllot',
			data: { Id }
		}).then((res) => {
			if (res) {
				state.info.Data = res
				state.loading = false
			}
		})
	}

	onLoad(async (query) => {
		if (query.Id) {
			state.pageName = '兽药调拨详情'
			getDetails(query.Id)
		}
	});
</script>
<style lang="scss" scoped>
	.card {
		position: relative;
		width: calc(100% - 60rpx);
		margin: 20rpx auto;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		border-radius: 6rpx;

		.card-index {
			position: absolute;
			display: flex;
			width: 40rpx;
			height: 40rpx;
			padding-left: 10rpx;
			font-size: 24rpx;
			background: #409eff;
			color: #fff;
			clip-path: polygon(0 0, 0 40rpx, 10rpx 40rpx, 40rpx 10rpx, 40rpx 0);
		}
	}
</style>